﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace MG_POS_PC.Util
{
    public  class XmlUtil
    {
        /*
        public static string key2valueUnits(string key)
        {
            XmlDocument xmlUnit = new XmlDocument();
            xmlUnit.Load(FileName.xmlUnits);
            XmlNodeList list = xmlUnit.SelectSingleNode("Units").ChildNodes;
            for (int i = 0; i < list.Count; i++)
            {
                XmlElement xe = (XmlElement)list[i];
                if (xe.Attributes.Count > 0 && xe.GetAttribute("Id") == key.Trim())
                {
                    return xe.GetAttribute("Ud_short");
                }
            }
            return null;
        }

        public static string value2keyUnits(string value)
        {
            XmlDocument xmlUnit = new XmlDocument();
            xmlUnit.Load(FileName.xmlUnits);
            XmlNodeList list = xmlUnit.SelectSingleNode("Units").ChildNodes;
            for (int i = 0; i < list.Count; i++)
            {
                XmlElement xe = (XmlElement)list[i];
                if (xe.Attributes.Count > 0 && xe.GetAttribute("Ud_short") == value.Trim())
                {
                    return xe.GetAttribute("Id");
                }
            }
            return null;
        }




        public static string key2valueDepts(string key)
        {
            XmlDocument xmldoc = new XmlDocument();
            xmldoc.Load(FileName.xmlDepts);
            XmlNodeList nodelist = xmldoc.SelectSingleNode("Departments").ChildNodes;
            for (int i = 0; i < nodelist.Count; i++)
            {
                XmlElement xe1 = (XmlElement)nodelist[i];
                if (xe1.Attributes.Count > 0 && xe1.GetAttribute("Id") == key.Trim())
                {
                    return xe1.GetAttribute("Name");
                }
            }
            return null;
        }

        public static string value2keyDepts(string value)
        {
            XmlDocument xmldoc = new XmlDocument();
            xmldoc.Load(FileName.xmlDepts);
            XmlNodeList nodelist = xmldoc.SelectSingleNode("Departments").ChildNodes;
            for (int i = 0; i < nodelist.Count; i++)
            {
                XmlElement xe1 = (XmlElement)nodelist[i];
                if (xe1.Attributes.Count > 0 && xe1.GetAttribute("Name") == value.Trim())
                {
                    return xe1.GetAttribute("Id");
                }
            }
            return null;
        }
         */ 
    }
}
